<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    	    <%@page import="beans.*"%>
<%@page import="service.*"%>
<%@page import="java.util.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Dashboard</title>
<link rel="stylesheet"
	href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" />
<style type="text/css">
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 20px;
    }
    
    table {
	border-collapse: collapse;
	width: 100%;
	margin-top: 20px;
	font-size: 16px;
}

table th, table td {
	border: 1px solid #ddd;
	padding: 8px;
	text-align: center;
}

table th {
	background-color: #f2f2f2;
	font-weight: bold;
}
    
    tr:hover {
      background-color: #eaeaea;
    }
    input[type="button"], input[type="submit"]{
	background-color: #4CAF50;
	border: none;
	color: #fff;
	padding: 10px 20px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 16px;
	border-radius: 10px;
	cursor: pointer;
}
input[type="button"]:hover , input[type="submit"]:hover{
	background-color: #3e8e41;
}
#c{
display:none;
}
#ca{
position: fixed;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            background-color: rgba(0, 0, 0, 0.5);
            
}
#cb{
margin: auto;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	height: 135px;
	width: 350px;
	background-color: white;
	text-align:center;
	border-radius: 10px;
         
}

#u{
display:none;
}
#ua{
position: fixed;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            background-color: rgba(0, 0, 0, 0.5);
            
}
label {
	display: inline-block;
	width: 200px;
	margin-bottom: 10px;
	font-weight: bold;
}
#ub{
margin: auto;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	height:150px;
	width: 780px;
	background-color: white;
	text-align:center;
	border-radius: 10px;

}
#ub > select{
	width: 500px;
	border-radius: 10px;
	padding: 10px;
	border: none;
	background-color: #f2f2f2;
	margin-bottom: 10px;
	font-size: 16px;
}
#reason{
	width: 480px;
	border-radius: 10px;
	padding: 10px;
	border: none;
	background-color: #f2f2f2;
	margin-bottom: 10px;
	font-size: 16px;
}
</style>
</head>
<body class="mdui-theme-primary-teal mdui-theme-accent-teal mdui-drawer-body-left" >



<div class=".mdui-ripple">
    <div class="mdui-toolbar mdui-color-theme">
        <a href="javascript:;" class="mdui-btn mdui-btn-icon">
            <i class="mdui-icon material-icons " id="toggle">menu</i>
        </a>
        <span class="mdui-typo-title">Dashboard</span>
        <div class="mdui-toolbar-spacer"></div>
        <div class="mdui-textfield mdui-textfield-expandable mdui-float-right">
            <button class="mdui-textfield-icon mdui-btn mdui-btn-icon" onclick="searchText()"><i class="mdui-icon material-icons">search</i></button>
            <input id="searchText" class="mdui-textfield-input" type="text" placeholder="Search"/>
            <button class="mdui-textfield-close mdui-btn mdui-btn-icon" ><i class="mdui-icon material-icons">close</i></button>
        </div>
       <a href="javascript:;" class="mdui-btn mdui-btn-icon" onclick="window.location='${pageContext.request.contextPath}/main.jsp'">
            <i class="mdui-icon material-icons">&#xe879;</i>
        </a>
        
    </div>
</div>


<div class="mdui-drawer" id="drawer">
    <ul class="mdui-list">
        <li class="mdui-subheader">医院仪表盘</li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/admin/index.jsp'">
            <i class="mdui-icon material-icons mdui-list-item-icon">&#xe871;</i>
            <div class="mdui-list-item-content">Dashboard</div>
        </li>
        <li class="mdui-subheader" >人员管理</li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/Main_Patient'">
            <i class="mdui-icon material-icons mdui-list-item-icon">&#xe914;</i>
            <div class="mdui-list-item-content">患者信息管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/Main_Doctor'">
            <i class="mdui-icon material-icons mdui-list-item-icon">&#xe566;</i>
            <div class="mdui-list-item-content">医生信息管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/Main_Admin'">
            <i class="mdui-list-item-icon mdui-icon material-icons">&#xe8b8;</i>
            <div class="mdui-list-item-content">管理员信息管理</div>
        </li>

        <li class="mdui-subheader">医院基础信息管理</li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/Main_Office'">
            <i class="mdui-list-item-icon mdui-icon material-icons">drafts</i>
            <div class="mdui-list-item-content">科室信息管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/admin/indentPage.jsp'">
            <i class="mdui-list-item-icon mdui-icon material-icons">email</i>
            <div class="mdui-list-item-content">订单信息管理</div>
        </li>

        <li class="mdui-subheader">医院排班信息管理</li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}/admin/doctorScheduling.jsp'">
            <i class="mdui-list-item-icon mdui-icon material-icons">&#xe05f;</i>
            <div class="mdui-list-item-content">医生排班管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location='${pageContext.request.contextPath}//Main_MZ'">
            <i class="mdui-icon material-icons mdui-list-item-icon">&#xe84f;</i>
            <div class="mdui-list-item-content">门诊管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location.href='${pageContext.request.contextPath}/admin/handleApplication.jsp'" href="javascript:void(0);">
            <i class="mdui-icon material-icons mdui-list-item-icon">&#xe85a;</i>
            <div class="mdui-list-item-content">医生申请处理管理</div>
        </li>
        <li class="mdui-list-item mdui-ripple" onclick="window.location.href='${pageContext.request.contextPath}/admin/doctorArrangeCancel.jsp'" href="javascript:void(0);">
            <i class="mdui-list-item-icon mdui-icon material-icons">&#xe5c9;</i>
            <div class="mdui-list-item-content">医生排班变动管理</div>
        </li>
    </ul>
</div>
<%
doctorSchedulingService doctorSchedulingService=new doctorSchedulingService();
mzService mzService = new mzService();
doctorService doctorService = new doctorService();
applicationService applicationService = new applicationService();
List<applicationBean> list=applicationService.browse();
%>
<table id="n">

			<thead>
				<tr>
					<th colspan="9">申请情况</th>
				</tr>
				<tr>
					<th style="display: none;">排班编号</th>
					<th>医生编号-姓名</th>
					<th>门诊编号-名称</th>
					<th>日期</th>
					<th>时间</th>
					<th>数量</th>
					<th>理由</th>
					<th>状态</th>
					<th>同意</th>
					<th>驳回</th>
				</tr>
				
			</thead>
			<tbody>
			<%
				int i=0;
				while(list!=null&&i<list.size()){%>
					<tr class="table-row">
					<td style="display: none;"><%=list.get(i).getSchid() %></td>
					<td><%=list.get(i).getDocid() %>-<%=doctorService.getRecord(list.get(i).getDocid()).getName() %></td>
					<td><%=doctorSchedulingService.getRecord(list.get(i).getSchid()).getMzid() %>-<%=mzService.getRecord(doctorSchedulingService.getRecord(list.get(i).getSchid()).getMzid()).getName() %></td>
					<td><%=doctorSchedulingService.getRecord(list.get(i).getSchid()).getDate() %></td>
					<%if(doctorSchedulingService.getRecord(list.get(i).getSchid()).getType().equals("100")){ %>
						<td>上午</td>
					<%}else if(doctorSchedulingService.getRecord(list.get(i).getSchid()).getType().equals("010")){%>
						<td>下午</td>
					<%}else{ %>
						<td>晚上</td>
					<%} %>
					<td><%=doctorSchedulingService.getRecord(list.get(i).getSchid()).getSum() %></td>
					<td><textarea disabled><%=list.get(i).getReason() %></textarea></td>
					<%if(list.get(i).getState().equals("待审核")){ %>
					<td>待审核</td>
					<%}else if(list.get(i).getState().equals("已取消")){ %>
					<td>已通过</td>
					<%}else{ %>
					<td><%=list.get(i).getState() %></td>
					<%} %>
					<%if(doctorSchedulingService.getRecord(list.get(i).getSchid()).getDate().getTime()<=new Date().getTime()||!list.get(i).getState().equals("待审核")){ %>
					<td><input type="button" class="btn" value="同意" style="background-color:grey"disabled></td>
					<td><input type="button" class="btn1" value="不同意" style="background-color:grey"disabled></td>
					<%}else{%>
					<td ><input type="button" class="btn"value="同意"></td>
					<td ><input type="button" class="btn1"value="不同意"></td>
					<%} %>
				</tr>
				<%i++;}%>
			</tbody>
		</table>
			<form id="u" action="../Main">
	<div id="ua">
	<div id="ub">
		<label>驳回理由：</label><br><textarea id="reason" name="reason"></textarea>
		<br> <input type="hidden" name="action"
			value="disagreeA" /> <input type="text" id="schid1"name="schid1" value="" style="display:none;">
			<input id="ub1"type="button" value="确定"
			> <input id="ub2"type="button" value="取消">
	</div>
	</div>
	</form>
	<form id="c" action="../Main">
	<div id="ca">
	<div id="cb">
	<h3>确定同意该医生的此次申请吗？</h3>
	<input type="hidden" name="action" value="agreeA"> 
	<input type="text" id="schid"name="schid" value="" style="display:none;">
	<input id="cba"type="submit" value="确定">
	<input id="cbb"type="button" value="取消">
	</div>
	</div>
	</form>
		
	<script type="text/javascript">
	document.querySelectorAll('.btn').forEach(item => {
		  item.addEventListener('click', event => {
			  var c = document.getElementById('c');
			   c.style.display="block";
			   var row = event.target.closest(".table-row");
		      var cba = document.getElementById('cba');
		      var cbb = document.getElementById('cbb');
		      cba.addEventListener('click', function () {
		           var cells=row.querySelectorAll("td");
		           var schid = document.getElementById('schid');
		           schid.value=cells[0].textContent;
		         	alert("已同意");
		       });

		      cbb.addEventListener('click', function () {
		   	   var c = document.getElementById('c');
		   	   c.style.display="none";
		       });
		  })
		});
	document.querySelectorAll('.btn1').forEach(item => {
		  item.addEventListener('click', event => {
			  var u = document.getElementById('u');
			   u.style.display="block";
			   var row = event.target.closest(".table-row");
		      var uba = document.getElementById('ub1');
		      var ubb = document.getElementById('ub2');
		      uba.addEventListener('click', function () {
		    	  var reason=document.getElementById('reason');
	            	if(reason.value==""){
	            		alert("请填写完整信息");
	            	}else{
	            		var cells=row.querySelectorAll("td");
	 		           var schid1 = document.getElementById('schid1');
	 		           schid1.value=cells[0].textContent;
	 		         	alert("已驳回");
	 		         	u.submit();
	            	}
		       });

		      ubb.addEventListener('click', function () {
		   	   var u = document.getElementById('u');
		   	   u.style.display="none";
		       });
		  })
		});
	
	</script>
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
<script>
    var $ = mdui.$;
    var inst = new mdui.Drawer('#drawer');
    $('#toggle').on('click', function () {
        inst.toggle();
    });
</script>
</body>
</html>